package com.map;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Test {

	private static String urlstr = "http://api.map.baidu.com/geosearch/v3/nearby?ak=CFL4XGsVFYGGbmW528grPDu7&geotable_id=123060&location=113.681942,34.762978&radius=2000";
	
	public static void main(String[] args) throws Exception {
		
		URL url = new URL(urlstr);
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("GET");
		httpConn.setRequestProperty("Content-Type",
				"application/x-www-form-urlencoded; charset=utf-8");
		httpConn.setDoOutput(true);
		httpConn.setDoInput(true);
		httpConn.setUseCaches(false);
		httpConn.setInstanceFollowRedirects(false);
		OutputStream out = httpConn.getOutputStream();
		BufferedReader in = new BufferedReader(new InputStreamReader(
				httpConn.getInputStream(), "utf-8"));
		String line = "";
		StringBuilder answer = new StringBuilder();
		while ((line = in.readLine()) != null) {
			answer.append(line);
		}
		System.out.println(answer.toString());
	}
}
